<?php

namespace App\BO\Payment;

use App\BO\PaymentState\PaymentStateDefinition;
use App\Entities\PaymentEntity;
use App\Utils\TradeNoGeneratorUtil;

class PaymentFactory
{
    /**
     * @param int $orderType
     * @param int $amount
     * @return PaymentEntity
     */
    public static function getNewPaymentInstance(int $orderType, int $amount)
    {
        $paymentEntity = PaymentEntity::getNewInstance();
        $paymentEntity->setState(PaymentStateDefinition::STATE_WAITING_PAY);
        $paymentEntity->setOrderType($orderType);
        $paymentEntity->setTradeNo(TradeNoGeneratorUtil::get());
        $paymentEntity->setAmount($amount);
        return $paymentEntity;
    }
}
